<?php

namespace App\Kuafu\Mqtt\Controller\Pos;

use App\Kuafu\Base\Controller\BaseController;

use App\Kuafu\Mqtt\Service\MqttWebHookService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class OnlineController extends BaseController
{

    public function mqttWebhook(Request $request): \Illuminate\Http\JsonResponse
    {
        $requestAll = $request->all();
        Log::channel('mqtt')->info('request-all', $request->all());

        $event = $requestAll['event'];

        (new MqttWebHookService())
            ->setEvent($event)
            ->deal($requestAll);

        return $this->success();
    }
}